﻿<cfsilent>
	<cfscript>
		
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "论文管理 - 添加学生");
		
		studentId = event.getArg("stu");
		
		teacherId = event.getArg("tchId");
		
		passArgs = structNew();
		
		currentTab = event.getArg("TabID", "labSearch");
		
	
		/* 搜索学生档案 */
		cases = event.getArg("cases");
		HSQL = "";
		keyword = trim(event.getArg("Keywords")) ;
		
		if( cases eq "" OR cases eq "1"){
			cases = "1";
			keyword = ucase(keyword);
			HSQL = "upper( ";
		}else if( cases eq "2"){
			keyword = lcase(keyword);
			HSQL = "Lower( ";
		}else{
			HSQL = "(";
		}
		
		structInsert(passArgs,"cases", cases );
		structInsert(passArgs,"tchId", teacherId );
		

		rs_student = queryNew("stu_id");
		
		if ( len(keyword) ) {
			
			
			sql = "SELECT 
						 " & HSQL & " t_student.stu_id ) stu_id,
						 " & HSQL & " t_student.stu_name_english ) stu_name_english, 
						 " & HSQL & " t_student.NATIONALITY ) NATIONALITY, 
						 " & HSQL & " t_student.stu_idcard ) stu_idcard, 
						 " & HSQL & " t_student.stu_name ) stu_name, 
						 " & HSQL & " t_student.stu_sex ) stu_sex, 
						 t_student_status.student_prop,
						 (SELECT tch_name FROM t_teacher where t_teacher.tch_id = t_student.tch_id_paper) tch_name 
					FROM 
						 t_student 
						 INNER JOIN t_student_status ON t_student_status.stu_id = t_student.stu_id 
					WHERE 
						 (
							 " & HSQL & " t_student.stu_id ) LIKE :condition 
							 OR 
							 " & HSQL & " t_student.stu_name ) LIKE :condition 
							 OR 
							 " & HSQL & " t_student.stu_name_english ) LIKE :condition 
							 or 
							 " & HSQL & " T_STUDENT.stu_idcard ) LIKE :condition 
							 OR 
							 " & HSQL & " t_student.NATIONALITY ) like :condition 
						 )
					ORDER BY 
						 t_student.stu_name ";
			
			queryObj = new Query( datasource=application.dnsSlave, maxRows=30 );
			queryObj.addParam( name="condition", value="%"&keyword&"%", cfsqltype="cf_sql_varchar" );
			
			rs_student = queryObj.execute( sql=sql ).getResult();
	
						
		}
		
		rs_studentEntity = queryNew("stu_id");
		rs_teacher = queryNew("tch_id");
		
		if ( len(studentId) ) {
			
			currentTab = event.getArg("TabID", "labForm");
			
			
			sql = "SELECT a.stu_id, a.stu_name, a.stu_name_english, b.date_join, a.stu_birthday 
					FROM t_student a 
					INNER JOIN t_student_status b ON b.stu_id = a.stu_id
					WHERE lower(a.stu_id) = :studentId ";
		
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="studentId", value=lcase(studentId), cfsqltype="cf_sql_varchar" );
			
			rs_studentEntity = queryObj.execute( sql=sql ).getResult();
			
			sql = "SELECT tch_id,tch_name 
					FROM t_teacher a 
					WHERE tch_id = :teacherId ";
		
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
			
			rs_teacher = queryObj.execute( sql=sql ).getResult();
			
		}

		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentOfPaper',passArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">返回学生列表</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>把学生添加给论文指导教师
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索学生信息</span>
                              <cfif len(studentId)>
							<span <cfif currentTab eq "labForm">class="active"</cfif> id="labForm" tabTarget="Form">添加学生管理</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentSearchOfPaper',passArgs)#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
						<div class="label">
							<b>学号、中文名、国家、<br/>护照名、护照号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
                                   <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="1" <cfif event.getArg('cases', '1') eq 1>checked="checked"</cfif> />大写显示
                                    <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="2" <cfif event.getArg('cases', '1') eq 2>checked="checked"</cfif>/>小写显示
                                     <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="3" <cfif event.getArg('cases', '1') eq 3>checked="checked"</cfif>/>正常显示
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_student.recordCount>

                              
							<cfset row = 0 />
                                   <table class="UIEditable">
                                        <thead>
                                             <tr>
                                                  <td width="18"></td>
                                                  <td>学号</td>
                                                  <td>中文名</td>
                                                  <td>性别</td>
                                                  <td>护照名</td>
                                                  <td>护照号</td>
                                                  <td>国籍</td>
                                                  <td align="center">论文指导教师</td>
                                                  <td width="18"></td>
                                             </tr>
                                        </thead>
                                        <tbody>
                                     <cfloop query="rs_student">
                                                  
                                                  <cfset row++ />
                                                  
                                                  <cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
                                                  <cfset structInsert(passArgs,"Keywords", keyword,true ) />
                                                  
                                                  <cfset propertyAdvice.parseProperty(rs_student.student_prop) />
                                                  
                                                  <tr class="editRows <cfif not propertyAdvice.getInSchool()>alertRow</cfif>">
                                                       <td class="index"><cfoutput>#row#</cfoutput></td>
                                                       <td><cfoutput>#replace(rs_student.stu_id,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                                       <td><cfoutput>#replace(rs_student.stu_name,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                                       <td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
                                                       <td><cfoutput>#replace(rs_student.stu_name_english,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                                       <td><cfoutput>#replace(rs_student.stu_idcard,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                                       <td><cfoutput>#replace(rs_student.nationality,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                                       <td align="center"><cfif rs_student.tch_name eq "">无<cfelse><cfoutput>#rs_student.tch_name#</cfoutput></cfif></td>
                                                       <td><a href="<cfoutput>#buildURL('studentSearchOfPaper', passArgs)#</cfoutput>" class="stat select"></a></td>
                                                  </tr>
                                             </cfloop>
                                        </tbody>
                                   </table>
                              
					
					</cfif>
					
				</div>
                    
                    <cfif len(studentId)>
				
					<div id="Form" class="tabContent">
					
						<div class="noticeBlock">
							<h3>论文指导教师添加学生</h3>
						</div>
					
						
						<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper" method="post" action="<cfoutput>#buildURL('stuAddPaperTeacherDo')#</cfoutput>">
                              
							<input type="hidden" name="StudentID" value="<cfoutput>#studentId#</cfoutput>" />
                                   <input type="hidden" name="tchID" value="<cfoutput>#teacherId#</cfoutput>" />
                                   <input type="hidden" name="tchName" value="<cfoutput>#rs_teacher.tch_name#</cfoutput>" />
                                   <input type="hidden" name="studentName" value="<cfoutput>#rs_studentEntity.stu_name#</cfoutput>" />
							
							<div class="label">
								<b>待添加学生</b>
								<input type="text" readonly="readonly" name="stuName" class="typeTextReadOnly" value="姓名：<cfoutput>#rs_studentEntity.stu_name#</cfoutput>" />
                                        <input type="text" readonly="readonly" name="StudentNUm" class="typeTextReadOnly" value="学号：<cfoutput>#rs_studentEntity.stu_id#</cfoutput>" />
                                        <input type="text" readonly="readonly" name="StudentEngName" class="typeTextReadOnly" value="护照名：<cfoutput>#rs_studentEntity.stu_name_english#</cfoutput>" />
                                        <input type="text" readonly="readonly" name="Studentbirthday" class="typeTextReadOnly" value="生日：<cfoutput>#rs_studentEntity.stu_birthday#</cfoutput>" />
                                         <input type="text" readonly="readonly" name="Studentdatejoin" class="typeTextReadOnly" value="入学日期：<cfoutput>#rs_studentEntity.date_join#</cfoutput>" />
                                         
							</div>

							<div class="label">
								<b>论文指导教师</b>
								<input type="text" readonly="readonly" name="tName" class="typeTextReadOnly" value="名字：<cfoutput>#rs_teacher.tch_name#</cfoutput>(<cfoutput>#rs_teacher.tch_id#</cfoutput>)" />
                                        
                                        <p class="notice">
									请仔细核对教师和学生, 确认无误后再继续
								</p>
							</div>
							
							
							<hr/>
						
							<div class="lable">
								<input class="button" type="submit" value="添加" />
							</div>
							
						</form>
					
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>